package com.example.demo2.controller;


import com.example.demo2.bean.Girl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/girl")
public class HelloWorldController {

    private static final Logger logger = LoggerFactory.getLogger(HelloWorldController.class);

    @Autowired
    Girl girl;

    @Value("${name}")
    private String name;
    @Value("${age}")
    private Integer age;
    @Value("${cupSize}")
    private String cupSize;

    @GetMapping("/hello/{name}/{age}/{cupSize}")
    public String hello(@PathVariable String name, @PathVariable Integer age, @PathVariable String cupSize) {
        logger.info("罩杯是{},姓名是{}", cupSize, name);
        return String.format("我叫%s,今年%d,%s杯", name, age, cupSize);
    }

    @GetMapping("/hello")
    public String whatCup(String weight) {

        logger.info("体重是{}", weight);
        return String.format("我叫%s,今年%d,%s杯,体重%s", this.name, this.age, this.cupSize, weight);
    }

    @GetMapping("/world")
    public String world(String weight) {

        logger.info("体重是{}", weight);
        return String.format("我叫%s,今年%d,%s杯,体重%s,性别%s", girl.getName(), girl.getAge(), girl.getCupSize(), girl.getGender(), weight);
    }
}
